<?php

class Mount extends \Eloquent {
	protected $fillable = [];


    public function area(){
        return $this->belongsTo('Area');
    }
    public function customer(){
        return $this->belongsTo('Customer');
    }

    public function xiaoqu(){
        return $this->belongsTo('Area','area_id','id');
    }
    public function section(){
        return $this->belongsTo('Area','section_id','id');
    }
    public function cityname(){
        return $this->belongsTo('Area','city','id');
    }

    public function machine(){
        return $this->belongsTo('Machine');
    }

    public function pictures(){
        return $this->hasMany('Picture');
    }

    public static function insert_try($customer_id,$name, $mobile, $address, $sex,$area_id,$section_id,$remark,$city,$machine,$code = null,$state=0,$type=null,$created_at)
    {

        if(!$city){
            $city = 0;
        }
        $mount = new Mount;
        if($state == 1){
            $mount->shiyong_start = time();
        }
        $mount->customer_id   = $customer_id;
        $mount->mount_name   = $name;
        $mount->mount_mobile   = $mobile;
        $mount->address   = $address;
        $mount->city = $city;
        $mount->sex   = $sex;
        $mount->area_id   = $area_id;
        $mount->section_id   = $section_id;
        $mount->machine_id   = $machine;
        $mount->remark = $remark;
        $mount->code = $code;
        $mount->state = $state;
        $mount->type = $type;
        $mount->created_at = $created_at;
        $mount->save();
        return $mount->id;
    }
}